package router

import (
	"github.com/starmotioncf/soutchatinternal/handler"
	"github.com/starmotioncf/soutchatinternal/middleware"

	"github.com/gin-gonic/gin"
)

type OpenapiRouter struct {
	openapiMiddleware *middleware.OpenapiMiddleware
	commonHandler     *handler.CommonHandler
}

func NewOpenapiRouter(openapiMiddleware *middleware.OpenapiMiddleware,
	commonHandler *handler.CommonHandler) *OpenapiRouter {
	return &OpenapiRouter{
		openapiMiddleware: openapiMiddleware,
		commonHandler:     commonHandler,
	}
}

func (r *OpenapiRouter) Register(g gin.IRouter) {
	// 注册中间件
	g = g.Group("", r.openapiMiddleware.Handle)
	//注册路由
	r.test(g)
}

func (r *OpenapiRouter) test(g gin.IRouter) {
	g.GET("/test_openapi", r.commonHandler.Version)
}
